package thread;

import java.util.concurrent.ThreadFactory;

public class CustomThreadPool implements ThreadFactory {

    private int threadCount = 0;
    private String name;

    public CustomThreadPool(String name){
        this.name = name;
    }


    @Override
    public Thread newThread(Runnable r) {
        threadCount++;
        Thread thread = new Thread(r,name + "Thread - " + threadCount);
        // 设置线程的优先级，是否为守护线程
        thread.setPriority(Thread.NORM_PRIORITY);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return thread;
    }
}
